<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  <link rel="stylesheet" href="./layui-v2.6.8/layui/css/layui.css">
  <script src="./js/jquery-2.1.4.min.js"></script>
  <script src="./layui-v2.6.8/layui/layui.js"></script>
</head>

<body>
<div style="text-align: center;">
  <ul class="layui-nav" lay-bar="disabled">
    <li class="layui-nav-item" style="">
      <span>用户设置</span>
    </li>
    <li class="layui-nav-item" style="float: right">
      <a href="./home.html">返回</a>
    </li>

  </ul>
  <div class="layui-inline">
    <form class="layui-form" action="/updateUser" >
      <div class="layui-form-item">
        <input type="hidden" id="userId" >
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
          <input id=“username” type="text"   name="name" required  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">新密码</label>
        <div class="layui-input-inline">
          <input  id="p1" type="password" name="pwd" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>

      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">密码确认</label>
        <div class="layui-input-inline">
          <input  id="p2" type="password"  required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
<!--        <div ></div>-->
      </div>

      <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">个性签名</label>
        <div class="layui-input-block">
          <textarea id="note" name="note"  class="layui-textarea"></textarea>
        </div>
      </div>
      <div class="layui-form-item">
        <div class="layui-input-block">
          <button class="layui-btn" lay-submit lay-filter="formDemo" ><a href="login.html" target="_parent">修改完成</a></button>
        </div>
      </div>
    </form>
  </div>

</div>


<script>
  var id=1;

  $(function () {
    getUserById(id);

  });
  // Demo
  layui.use('form', function(){
    var form = layui.form;

    //监听提交
    form.on('submit(formDemo)', function(data){
      layer.msg(JSON.stringify(data.field));

    });
  });



  // $("#p2").onblur(function () {
  //   if ($("#p2").text()!=$("#p1").text()){
  //     $("#mes").html(<span style="color:red">密码错误</span>);
  //   };
  //   if ($("#p2").text()==$("#p1").text()){
  //     $("#mes").html(<span style="color:green">输入正确</span>);
  //   }
  // });

  function getUserById(id) {
    $.ajax({
      url: '/getUser/' + id,
      type: 'GET',
      data: "",
      success: function (result) {
        layer.msg("修改成功",{
          time:300
        });
        var name=result.extend.userName;
        var note_text=result.extend.note;
        $("username").text(name);
        $("note").text(note_text);
        windows.parent.location.href='login.html'
      },

    });
  }


</script>

</body>
</html>
